package org.baicaixiaozhan.io;

import java.io.File;

/**
 * DESC:
 *
 * @author : baicaixiaozhan
 * @since : 2020-12-21
 */
public interface AbstractCryptoFileFeatures<T, R> {

    /**
     * get file`s byte arrays
     *
     * @param file file that will be read
     * @return byte arrays
     */
    default byte[] readFile(File file) { return new byte[0]; }

    /**
     * write file data to filePath
     *
     * @param filePath file output path
     * @param data file data
     */
    default void writeFile(String filePath, byte[] data) {}

    /**
     * encryption data to file
     *
     * @param data data that will be encryption
     * @param filePath encryption file`s output path
     */
    void encryptDataToFile(T data, String filePath);

    /**
     * decryption file to R data
     *
     * @param filePath that will be decryption file path
     * @return R
     */
    R decryptFileToObject(String filePath);
}
